<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="../common/taglibs.jsp"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
  
    <title>操作员权限分配</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	<link href="<s:url value="/css/common.css"/>" type="text/css"	rel="stylesheet" />
	<script type="text/javascript" src="<c:url value="/js/jquery-1.3.2.js" />"></script>   
	<script type="text/javascript" src="<c:url value="/js/common.js" />"></script>
	<script language="javascript" type="text/javascript" src="<c:url value="/js/My97DatePicker/WdatePicker.js"/>"></script>
  
	<style type="text/css">
  
		.tb_h3 {
		  color: #000;
		  height: 22px;
		  line-height: 22px;
		  font-size: 12px;
		  font-family: "Microsoft YaHei", Arial, sans-serif;
		  padding: 0 5px;
		  font-weight: 700;
		}
	</style> 
  <script type="text/javascript">
  
<!--
function goback(){
  	history.go(-1);
  }
  
 function selectAllEvent(objCheckbox){
	 	var tempObj=$(objCheckbox);
	 	if(tempObj.attr('checked')){
	 		var tableId=tempObj.attr('name');
	    	$('#'+tableId).find(":checkbox[name=list]").each(function(){
	   		 	$(this).attr('checked',true);
	 	 	}); 
	 	}else{
	 		var tableId=tempObj.attr('name');
	    	$('#'+tableId).find(":checkbox[name=list]").each(function(){
	   		 	$(this).attr('checked',false);
	 	 	}); 
	 	}
	} 

$(document).ready(function(){
    $("#backBtn").click(function(){
       self.history.back(1);
       return false;
    });
  
    $(":checkbox[name=list]").each(function(){
		  var tableId=$(this).closest("table").attr('id');
		  var checkedNumber=$('#'+tableId).find(":checkbox[name=list]:checked").length;
		  var totalNumber=$('#'+tableId).find(":checkbox[name=list]").length;
		  var checkAllObj=$('#'+tableId).closest("tr").prev().find(":checkbox[name="+tableId+"]");
		  if(checkedNumber==totalNumber){
			  checkAllObj.attr('checked',true);
		  }else{
			  checkAllObj.attr('checked',false);
		  }
		  $(this).click(function(){
			  checkedNumber=$('#'+tableId).find(":checkbox[name=list]:checked").length;
			    if(checkedNumber==totalNumber){
			    	checkAllObj.attr('checked',true);
			    }else{
			    	checkAllObj.attr('checked',false);
			    }
		  });
		 var tdObj=$(this).closest('td');
		 tdObj.find('label').click(function(){		
			 tdObj.find(":checkbox[name=list]").each(function(){
					if($(this).attr('checked')){
						$(this).attr('checked',false);
					}else{
						$(this).attr('checked',true);
					}
					checkedNumber=$('#'+tableId).find(":checkbox[name=list]:checked").length;
					if(checkedNumber==totalNumber){
						  checkAllObj.attr('checked',true);
					 }else{
						 checkAllObj.attr('checked',false);
					 }
			 });
		 });
	 });
 
});
-->
</script>
  </head>
  
  <body>
   	<s:form id="athourityForm" action="/model/saveModel.ct" method="post"  theme="simple">
    	<s:hidden name="merchant.id"></s:hidden>
     
	<table width="100%" class="tb" >
		<tr class="tb-line">
			<td class="tb-td" colspan="6">
				<div class="tb-h2">POS收单运营管理平台</div>
			</td>
		</tr>
		<tr class="tb-line bg-gray">
			<td class="tb-td" colspan="4"><div class="tb-h3">用户权限模板信息</div></td>
		</tr>
		<tr class="tb-line">
			<td align="right" class="tb-td" style="width:110px;">
				<div class="tb-h4">模板编码:</div>
			</td>
			<td class="tb-td" >
				<label class="tb-input-lengthen">
					<s:textfield cssClass="fullWidth" id="modelCode" name="modelHead.modelCode" readonly="true"/>
				</label>
			</td>
			<td align="right" class="tb-td" style="width:110px;">
				<div class="tb-h4">权限模板名:</div>
			</td>
			<td class="tb-td" >
				<label class="tb-input-lengthen">
					<s:textfield cssClass="fullWidth" id="modelName" name="modelHead.modelName" />
				</label>
			</td>
		</tr>
		<tr class="tb-line">
			<td align="right" class="tb-td" style="width:110px;">
				<div class="tb-h4">权限模板备注：</div>
			</td>
			<td class="tb-td" colspan="3" style="height:auto;line-height:auto;"  >
				<label style="height:auto;line-height:auto;">
					<s:textarea rows="5" name="modelHead.remark" 
					  style="height: 102px; resize: none; width: 443px;padding:0 5px;" />
				</label>
			</td>
		</tr>		
	</table>
	
	<table id="userRight" width="100%" class="tb" >
	<tbody>
		<s:iterator value="#request.moduleList" status="stat" id="element">
			<tr class="tb-line bg-gray">
				<td  align="left" class="tb-td tb_h3"  colspan="2">
					<s:property value="#element.moduleCategoryName"/>
				 	<s:checkboxlist list="#{#element.moduleCategoryCode:''}" name="%{#element.moduleCategoryCode}"   
				 		cssClass="checkbox" onclick="selectAllEvent(this)"/>
				</td>
			</tr>
			<tr class="tb-line">
				<td colspan="2">
					<table id="${element.moduleCategoryCode}" class="standerWidth" border="0" cellpadding="0" cellspacing="1">
						<tbody>
							<tr>
								<td width="20" >&nbsp;</td>
								<s:iterator value="#element.modules" status="st" id="module">									
									<td width="140" class="label tb-h4">
										<s:checkboxlist name="list" list="#{#module.moduleCode:''}" cssClass="checkbox"></s:checkboxlist>
										<label><s:property value="#module.moduleName"/></label>
									</td>						
								</s:iterator>
								<td>&nbsp;</td>
							</tr>
						</tbody>
					</table>
				</td>
			</tr>
	
		</s:iterator>
		<s:hidden name="accountNo" id="accountNo" value="%{#request.accountNo}"/>
			<tr class="tb-line">
				<td class="tb-td line-submit" align="center" colspan="4">
					<label class="tb-input-submit">
						<s:submit  id="btnSave" value="保  存" ></s:submit>
					</label>
					<label class="tb-input-submit">
						<s:submit id="backBtn" value="返  回" ></s:submit>
					</label>
				</td>
			</tr>
		</tbody>
	</table>
   </s:form>
    
  </body>
</html>
